package com.song.auth.controller;

import com.song.common.domain.entity.UmsSysUser;
import com.song.common.service.IUmsSysUserService;
import com.song.common.response.DaoCaoResult;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/sysUser")
public class UmsSysUserController {

    private final IUmsSysUserService sysUserService;

    public UmsSysUserController(IUmsSysUserService sysUserService) {
        this.sysUserService = sysUserService;
    }

    /**
     * 查询列表
     */
    @GetMapping("/list")
    public DaoCaoResult list() {
        List<UmsSysUser> list = sysUserService.list();
        return DaoCaoResult.success(list);
    }

    /**
     * 新增用户
     */
    @PostMapping
    public DaoCaoResult addSysUser(@RequestBody UmsSysUser user) {
        boolean success = sysUserService.save(user);
        if (success) {
            return DaoCaoResult.success("新增用户成功");
        }
        return DaoCaoResult.error("新增用户失败");
    }

}
